package com.cb.staservice.controller;


import com.cb.staservice.client.UcenterClient;
import com.cb.staservice.service.StatisticsDailyService;
import com.cb.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author Cebb
 * @since 2020-07-01
 */
@Api(description = "网站统计数据管理")

@RestController
@RequestMapping("/staservice/sta")
public class StatisticsDailyController {

    private final StatisticsDailyService dailyService;

    @Autowired
    public StatisticsDailyController(StatisticsDailyService dailyService) {
        this.dailyService = dailyService;
    }

    @ApiOperation("统计某天注册人数")
    @PostMapping("registerCount/{day}")
    public R registerCount(@PathVariable("day") String day) {
        dailyService.registerCount(day);
        return R.ok();
    }

    @ApiOperation("图表显示, 根据查询类型、开始时间、结束时间查询")
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable("type") String type,
                      @PathVariable("begin") String begin,
                      @PathVariable("end") String end){

        Map<String,Object> map = dailyService.getShowData(type, begin, end);
        return R.ok().data(map);
    }

}

